

-- 打包容器内所有物品并丢出来
function WrapContainerItems(inst, pos) -- inst 为容器 pos 选填
    pos = pos or inst:GetPosition()

    if not inst.components.container or inst.components.container:IsEmpty() then
        return
    end

    inst.components.container.ignoreoverstacked = true  --若不加这个，会丢弃超过堆叠上限的部分而不打包
    local items = inst.components.container:RemoveAllItems()
    inst.components.container.ignoreoverstacked = false 

    local gift = SpawnPrefab("gift")
    gift.components.unwrappable:WrapItems(items, inst)
    gift.Transform:SetPosition(pos:Get())
    Launch(gift, gift, 1)

    for k, v in pairs(items) do
        v:Remove()
    end
end